package com.mark.article.controller.v1;

import com.mark.article.apis.ArticleSearchControllerApi;
import com.mark.article.service.ApArticleSearchService;
import com.mark.model.article.dtos.UserSearchDto;
import com.mark.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description :  java类作用描述
 * @Author :  Markburt
 * @CreateDate :  2020/2/25$ 下午 12:45$
 * @UpdateUser :  Markburt
 * @UpdateDate :  2020/2/25$ 下午 12:45$
 * @UpdateRemark :  Project Build
 * @Version :  1.0
 */
@RestController
@RequestMapping("/api/v1/article/search")
public class ArticleSearchController implements ArticleSearchControllerApi {


    @Autowired
    private ApArticleSearchService apArticleSearchService;


    /**
     * 查询搜索历史
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/load_search_history")
    public ResponseResult findUserSearch(@RequestBody UserSearchDto dto) {
        return apArticleSearchService.findUserSearch(dto);
    }


    /**
     * 删除搜索历史
     *
     * @param dto
     * @return
     */

    @Override
    @PostMapping("/del_search")
    public ResponseResult delUserSearch(@RequestBody UserSearchDto dto) {
        return apArticleSearchService.delUserSearch(dto);
    }


    /**
     * 清空搜索历史记录
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/clear_search")
    public ResponseResult clearUserSearch(@RequestBody UserSearchDto dto) {
        return apArticleSearchService.clearUserSearch(dto);
    }


    /**
     * 今日热词
     *
     * @param dto
     * @return
     */

    @Override
    @PostMapping("/load_hot_keywords")
    public ResponseResult hotkeywords(@RequestBody UserSearchDto dto) {
        return apArticleSearchService.hotkeywords(dto.getHotDate());
    }


    /**
     * 模糊查询联想词
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/associate_search")
    public ResponseResult searchassociate(@RequestBody UserSearchDto dto) {
        return apArticleSearchService.searchAssociate(dto);
    }


    /**
     * es文章分页查询
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/article_search")
    public ResponseResult esArticleSearch(@RequestBody UserSearchDto dto) {
        return apArticleSearchService.esArticleSearch(dto);
    }
}
